const util = require('../../utils/util.js')
const app = getApp();
Page({
  onGotUserInfo:function(e){
    var data = e.detail;
    wx.login({
      success:function(res){
        let code = res.code;
        // console.log('code'+code);
        let param = {};
        param.code = code;
        param.avatar = data.userInfo.avatarUrl;
        param.nickName = data.userInfo.nickName;
        util.commonRequestLogin('index/Login/getUserInfo','post',param,function(res){
          console.log('aaaaaaaaaaaaaaaaaaaaaaaaaa');
           if (res.data.code == 200)
           {
             wx.showToast({
               title: '登录成功',
             })
             wx.setStorageSync('userInfo', res.data.data);
             app.globalData.userInfo = res.data.data;
             wx.switchTab({
               url: '/pages/index/index'
             });
           }else{
             wx.showToast({
               title: res.data.msg,
               icon:'none'
             })
           }
        })
      }
    })
  }
})